package com.test.spring.service.impl;

import com.test.spring.data.User;
import com.test.spring.repository.UserMapper;
import com.test.spring.util.aspect.datasource.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by ll on 2017/4/4.
 */
@Service
public class UserServiceTestImpl {

    @Autowired
    private UserMapper userMapper;

//    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @DataSource(value = "masterDataSource")
    public void testB(int i) throws Exception {
        User user = new User();
        user.setId(i);
        user.setUserName("testB");
        userMapper.updateByPrimaryKeySelective(user);
        throw new Exception();
    }
}
